import { createSlice } from "@reduxjs/toolkit";

const initialState = { value: 0 }

export const countSlice = createSlice({
  name: 'count',
  initialState,
  reducers: {
    // 具体的reducer实现
    increment: (state) => {
      state.value += 1
    },
    decrement: (state) => {
      state.value -= 1
    },
    incrementByAmount: (state, action) => {
      state.value += action.payload
    }
  }
})
// 导出acitons
export const { increment, decrement, incrementByAmount } = countSlice.actions
// 导出reducer
export default countSlice.reducer